package dawn.jxufe.community.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.io.File;

/**
 * @author dawn21
 * @version 1.0
 * @date 2022/9/1 17:25
 * @component
 */
@Configuration // 配置类
public class WkConfig {

    private static final Logger logger = LoggerFactory.getLogger(WkConfig.class);

    @Value("${wk.image.storage}") // 注入路径。
    private String wkImageStorage;

    @PostConstruct // 服务启动时，加载配置类，实例化它，实例化时就会调用init()
    public void init() {
        // 创建wk图片目录。
        File file = new File(wkImageStorage);
        if (!file.exists()) {
            file.mkdirs();
            logger.info("创建wk图片目录：" + wkImageStorage);
        }
    }
}
